" Highlight special characters (those which have a backslash) differently
syn match rcSpecial contained "\\[0-7][0-7][0-7]\=\|\\."
syn region rcString start=+"+ skip=+\\\\\|\\"+ end=+"+ contains=rcSpecial
syn match rcCharacter "'[^\\]'"
syn match rcSpecialCharacter "'\\.'"
syn match rcSpecialCharacter "'\\[0-7][0-7]'"
syn match rcSpecialCharacter "'\\[0-7][0-7][0-7]'"
"catch errors caused by wrong parenthesis
syn region rcParen transparent start='(' end=')' contains=ALLBUT,rcParenError,rcIncluded,rcSpecial,rcTodo
syn match rcParenError ")"
syn match rcInParen contained "[{}]"
"integer number, or floating point number without a dot and with "f".
syn case ignore
syn match rcNumber "\<\d\+\(u\=l\=\|lu\|f\)\>"
"floating point number, with dot, optional exponent
syn match rcFloat "\<\d\+\.\d*\(e[-+]\=\d\+\)\=[fl]\=\>"
"floating point number, starting with a dot, optional exponent
syn match rcFloat "\.\d\+\(e[-+]\=\d\+\)\=[fl]\=\>"
"floating point number, without dot, with exponent
syn match rcFloat "\<\d\+e[-+]\=\d\+[fl]\=\>"
"hex number
syn match rcNumber "\<0x[0-9a-f]\+\(u\=l\=\|lu\)\>"
"syn match rcIdentifier "\<[a-z_][a-z0-9_]*\>"
syn case match
" flag an octal number with wrong digits
syn match rcOctalError "\<0[0-7]*[89]"
if exists("rc_comment_strings")
" A comment can contain rcString, rcCharacter and rcNumber.
" But a "*/" inside a rcString in a rcComment DOES end the comment! So we
" need to use a special type of rcString: rcCommentString, which also ends on
" "*/", and sees a "*" at the start of the line as comment again.
" Unfortunately this doesn't very well work for // type of comments :-(
syntax match rcCommentSkip contained "^\s*\*\($\|\s\+\)"
syntax region rcCommentString contained start=+"+ skip=+\\\\\|\\"+ end=+"+ end=+\*/+me=s-1 contains=rcSpecial,rcCommentSkip
syntax region rcComment2String contained start=+"+ skip=+\\\\\|\\"+ end=+"+ end="$" contains=rcSpecial
syntax region rcComment start="/\*" end="\*/" contains=rcTodo,rcCommentString,rcCharacter,rcNumber,rcFloat
syntax match rcComment "//.*" contains=rcTodo,rcComment2String,rcCharacter,rcNumber
else
syn region rcComment start="/\*" end="\*/" contains=rcTodo
syn match rcComment "//.*" contains=rcTodo
endif
syntax match rcCommentError "\*/"
syn region rcPreCondit start="^\s*#\s*\(if\>\|ifdef\>\|ifndef\>\|elif\>\|else\>\|endif\>\)" skip="\\$" end="$" contains=rcComment,rcString,rcCharacter,rcNumber,rcCommentError
syn region rcIncluded contained start=+"+ skip=+\\\\\|\\"+ end=+"+
syn match rcIncluded contained "<[^>]*>"
syn match rcInclude "^\s*#\s*include\>\s*["<]" contains=rcIncluded
"syn match rcLineSkip "\\$"
syn region rcDefine start="^\s*#\s*\(define\>\|undef\>\)" skip="\\$" end="$" contains=ALLBUT,rcPreCondit,rcIncluded,rcInclude,rcDefine,rcInParen
syn region rcPreProc start="^\s*#\s*\(pragma\>\|line\>\|warning\>\|warn\>\|error\>\)" skip="\\$" end="$" contains=ALLBUT,rcPreCondit,rcIncluded,rcInclude,rcDefine,rcInParen
syn sync ccomment rcComment minlines=10
if !exists("did_rc_syntax_inits")
let did_rc_syntax_inits = 1
" The default methods for highlighting. Can be overridden later
hi link rcCharacter Character
hi link rcSpecialCharacter rcSpecial
hi link rcNumber Number
hi link rcFloat Float
hi link rcOctalError rcError
hi link rcParenError rcError
hi link rcInParen rcError
hi link rcCommentError rcError
hi link rcInclude Include
hi link rcPreProc PreProc
hi link rcDefine Macro
hi link rcIncluded rcString
hi link rcError Error
hi link rcPreCondit PreCondit
hi link rcCommentString rcString
hi link rcComment2String rcString
hi link rcCommentSkip rcComment
hi link rcString String
hi link rcComment Comment
hi link rcSpecial SpecialChar
hi link rcTodo Todo
hi link rcAttribute rcCommonAttribute
hi link rcStdId rcStatement
hi link rcStatement Statement
" Default color overrides
hi rcLanguage term=reverse ctermbg=Red ctermfg=Yellow guibg=Red guifg=Yellow
hi rcMainObject term=underline ctermfg=Blue guifg=Blue
hi rcSubObject ctermfg=Green guifg=Green
hi rcCaptionParam term=underline ctermfg=DarkGreen guifg=Green